cleanup()
{
        echo "Caught Signal ... cleaning up."
        echo "Done cleanup ... quitting."
        exit 1
}

trap cleanup 1 2 3 5 15
while :
do
clear
echo "Enter an altitude:";
read altitude;
clear
echo "Enter the displayed flow:";
read flow;
clear
echo "Enter the temperature (c):";
read temp;
clear
#awk -v alt=${altitude} -v flow=${flow} '{ print flow/(1.001*exp(-.0000371*alt)) }'
pressure=$(awk -v alt=${altitude} 'BEGIN{ print 760*1.001*exp(-.0000371*alt) }')
awk -v alt=${altitude} -v temp=${temp} -v flow=${flow} -v pressure=${pressure} '(pf=((29.92)/(pressure/25.33))) (tf=(temp+273.15)/(273.15)) (ef=flow*tf*pf) { print ef " " flow/(1.001*exp(-.0000371*alt))END }' 
sleep 5
clear
done
exit
 